<!-- http://www.imooc.com/wiki/uniapp/databinding.html -->
<template>
	<view>
		
		<!-- 标题 -->
		<view class="page-title" @click="showName">
			<view class="page-title__wrapper">
				<text class="page-title__text">{{title}}</text>
			</view>
		</view>
		
		<intervalBar></intervalBar>
		
		<bdphonecode :phone_number_dc='phone_number' 
		:verify_code_dc='verify_code_dc'
		@retMsg='getMsg'
		@clickedverifyCodeButton='clickedverifyCodeButton'
		>
		</bdphonecode>
		
		<intervalBar></intervalBar>
		
		<!-- 姓名 -->
		<bdinput :dc='name' @retMsg='getMsg' v-if="forceReset" v-model='user_info.name'></bdinput>
		
		<!-- 选择性别 -->
		<bdpicker :dc='sex' @retMsg='getPickerMsg' v-if="forceReset"></bdpicker>
		<!-- 选择专业 -->
		<bdpicker ref="child" v-if="hackReset" :dc='selected_major' @retMsg='getPickerMsg'></bdpicker>
		<!-- 学校 -->
		<bdinput :dc='current_school' @retMsg='getMsg' v-if="forceReset"></bdinput>
		
		<bdinput :dc='current_class' @retMsg='getMsg' v-if="forceReset"></bdinput>
		
		<intervalBar></intervalBar>
		
		<!-- 省市区选择器 -->
		<view class="picker_view">
			<!-- 文本 -->
			<view class='picker_text'>
				<text>{{"地址选择"}}</text>
			</view>
			<view class="picker"  @click="addressShow = true" >
				<view class="picker_input">
					<input maxlength="20"
					:placeholder="address?address:'点击选择地址'"
					 disabled="true"
					 />
				</view>
				<uni-icons class="icons" type="arrowright" size="20"/>
			</view>
		    <view class="picker_address">
		        <pickerAddress v-model="addressShow" @confirm="addresspick" />
		    </view>
		</view>
		<!-- 详细地址 -->
		<bdinput :dc='address_detail' @retMsg='getMsg' v-if="forceReset"></bdinput>
		
		<intervalBar></intervalBar>
		
		<!-- 图片选择 -->
		<view class='images_container'>
			<view style="position: relative;"  v-for="(item, index) in getImageList()" :key="index">
				<view v-if="item">
					<view class='show_img_container'>
						<!-- <image class="shancs" src="/static/images/c1.png"></image> -->
						
						<!-- <image class="shancs" src="/pages/submitInfo/shanchus2.png" mode="" @click="selec(index)"></image> -->
						<image class="shancs" src="/static/images/shanchus2.png" mode="" @click="selec(index)"></image>
						<!-- <image class="shancs" src="./shanchus2.png" mode="" @click="selec(index)"></image> -->
						<image class='show_img' 
							@click="preview(item)"
							:src="item">
						</image>
					</view>
				</view>
				<view v-else>
					<view class='dont_have_img_container' @click="chooseImage(index)">
						<text class='img_text'>{{getImageTextList(index)}}</text>
					</view>
				</view>
			</view>
		</view>
		
		
		<intervalBar></intervalBar>
		
		<view class='buttons'>
			<!-- <button class='check_button' @click="checkData">图片校验</button> -->
			<button class='submit_button' @click="showData">提交数据</button>
		</view>
	</view>
</template>


<script>	
	import ttt from "components/bdpicker/ttt.vue"
	import bdpicker from "components/bdpicker/bdpicker.vue"
	import bdinput from "components/bdpicker/bdinput.vue"
	import bdphonecode from "../../components/bdpicker/bdphonecode.vue"
	import myPicker from "components/bdpicker/myPicker.vue"
	import intervalBar from "../../components/bdpicker/intervalBar.vue"
	import pickerAddress from '@/components/liudx-pickerAddress/index.vue'
	import * as util from 'util.js'
	export default {
		name:"forestRegistration",
		props: ['user_info'],
		//注册组件
		components: {
		  intervalBar,
		  bdpicker,
		  bdinput,
		  pickerAddress,
		  bdphonecode,
		  ttt,
		  myPicker
		},
		data () {
			return {
				verified: false,
				v: 123,
				imageStyles:{
					width: 128,
					height: 128,
					// border:{
					// 	color:"#ff5a5f",
					// 	width:2,
					// 	style:'dashed',
					// 	radius:'2px'
					// },
					// margin-left: 20,
					// padding: 20,
				},
				title: '预报名申请表',
				imageValue:[],
				// 前端界面信息
				current_class: {
					text: '班级',
					placeholder: '所在班级',
					value: '',
				},
				current_school: {
					text: '学校',
					placeholder: '所在学校',
					value: '',
				},
				address_detail: {
					text: '详细地址',
					placeholder: '请输入您的详细地址',
					value: '',
					maxlength: 30,
				},
				phone_number: {
					text: '手机号',
					placeholder: '请输入您的手机号',
					type: "number",
					value: '',
				},
				verify_code_dc: {
					text: '验证码',
					placeholder: '短信验证码',
					// type: "number",
					value: '',
				},
				name: {
					text: '姓名',
					placeholder: '请输入您的姓名',
					value: '',
				},
				
				// bdpiker
				sex: {
					text: '所选性别',
					placeholder: '请选择您的性别',
					names: ['男', '女'],
					value: '',
				},
				
				// 省市区
				addressShow: false,
				form: {
					// 默认内蒙古
				    province: "150000",
				    city: "150100",
				    area: "1501219f2a",
				},
				address: '',
				
				// ------- 专业选择
				selected_major: {
					text: '所选专业',
					placeholder: '请选择专业',
					// names: ['计算机', '挖掘机', '会计'],
					names: ['1', '2'],
					value: '',
					// add_placeholder_to_names: true,
				},
				major_list: [],
				hackReset: true,
				forceReset: true,		// v-if="forceReset"
				
				currentValue: '123',
				options: ["广东","上海","北京","深圳"],
				
				img_ls: [],
				
				picture_name_ls: ['picture_sign', 'picture_id_card_positive', 'picture_id_card_negative'],
			}
		},
		onLoad(){
			// uni.clearStorage();
			var accepted_items = uni.getStorageSync('accepted_items');
			if (!accepted_items){
				uni.showToast({
					title: '1111111'
				})
				function test(resolve, reject) {
						var that = this;
						uni.hideToast();
						uni.showModal({
							title: '服务条款',
							content: '根据教育部相关规定,\r\n 需要您上传身份证、电子签名等信息用于报名认证! \r\n 是否同意?',
							confirmText: "否",
							
							cancelText: "是",
							success: function(res) {
								console.log('~~~~~~~~~~~ success ', res);
								resolve(res)
								return
							},
							fail: function(res) {
								resolve(res)
								console.log('!!!!!!!!!!!!! fail', res);
							}
						});
				}
				var p1 = new Promise(test);
				let that = this;
				p1.then(function (result) {
					// 这里注意是反的, 左边为"是", 右边为"否"
				    console.log('成功返回：' + result.cancel);
					if (result.cancel){
						console.log('~~~~~~~~~~~ 用户同意了条款 ', 1111111111);
						uni.setStorageSync('accepted_items', 1);
						return 0
					}
					else {
						uni.navigateBack({
							
						})
					}
				})
				
				
			}
			
			this.init();
			this.getMajors();
		},
		onShow(){
			console.log('=== onShow from forestRegistraion ===');
			this.getValuesFromPrePage(this.picture_name_ls, this.user_info);
			// console.log('~~~ this._picture_sign: ', this['_picture_sign']);
		},
		
		methods: {
			onClickItem(val) {
				this.current = val.currentIndex
			},
			scollSwiper(e){
				this.current = e.target.current
			},
			setValue(key, value){
				this[key].value = value;
				this.user_info[key] = value;
			},
			onPullDownRefresh() {
				console.log('下拉刷新了111')
				uni.stopPullDownRefresh()
				
				this.page = 1
				this.goods = []
				this.flag = false
				setTimeout(()=>this.init(), 500)
				
				var url = '/pages/submitInfo/submitInfo';
				uni.navigateTo({
					url
				})
				// uni.reLaunch({
				//     url:url
				// });
			},
			init(){
				
				// uni.clearStorage();
				// 加载缓存
				// var value = 18510779120;
				var value = uni.getStorageSync('phone_number');
				
				// 初始化一些值, 便于测试
				this.setValue('phone_number', (value));
				this.setValue('verify_code_dc', 'ttod123');
				
				// this.phone_number.value = 18510779120;
				// this.user_info.phone_number = 18510779120;
				// this.verify_code_dc.value = 'ttod123';
				
			},
			getImageList(){
				let user_info = this.user_info;
				return [user_info.picture_sign, user_info.picture_id_card_positive, user_info.picture_id_card_negative]
			},
			getSelectFunctionList(){
				console.log();
				return [this.picture_sign, this.picture_id_card_positive, this.picture_id_card_negative]
			},
			
			getValuesFromPrePage(key_ls, set_dc){
				// --- 接收从上个页面传过来的值
				// key_ls: 从上一个页面中传过来的key
				// set_dc: 将这个dict的key设置为对应变量
				
				/* 调用页面获取图片URL方法 */
				let pages = getCurrentPages();
				let currPage = pages[pages.length-1];
				let that = this;
				
				for(var i in key_ls){
					var key_i = key_ls[i];
					var tmp_key_i = '_' + key_i;
					var value_i = currPage.data[tmp_key_i];
					
					// console.log('for --- ', tmp_key_i, '~~', value_i);
					
					if(typeof(value_i) != undefined && value_i != null){
						console.log('成功获取临时变量tmp_key_i: ', tmp_key_i, ' --- ', value_i);
						set_dc[key_i] = value_i;
						
						currPage.data[tmp_key_i] = null;		// 只获取一次
					};
				}
			},
			
			chooseImage(index) {
				var user_img_key = this.getImageList()[index];
				var img_name = this.picture_name_ls[index];
				var tmp_img_name = '_' + img_name;
				
				console.log('=== index, img_name, user_img_key: ', index, img_name, user_img_key);
				
				console.log('this.user_info', this.user_info);
				let that = this;
				
				if(img_name == 'picture_sign') {
					// 测试[手写电子签名]
					uni.navigateTo({
						url: '../contact/sign?key=' + tmp_img_name
					})
				}
				else if (img_name == 'picture_id_card_positive')  {
					uni.navigateTo({
						url: '../scan-frame/scan-frame?key=' + tmp_img_name
					})
				}
				else if (img_name == 'picture_id_card_negative') {
					uni.navigateTo({
						url: '../scan-frame/scan-frame?photo_text=身份证反面(人像面)&key=' + tmp_img_name
					})
				}
				else {
					uni.showToast({
						title: 'tmp_img_name取值错误!',
						icon: 'none'
					})
				}
				
				
				// const name_ls = ['picture_sign', 'picture_id_card_positive', 'picture_id_card_negative'];
				// this.getImageList()[index] = index;
				// this.user_info[name_ls[index]] = index;
				// console.log('======index', index, this.getImageList()[index]);
				
				
				// uni.chooseImage({
				//     count: 1, //默认9
				// 	sizeType: ['compressed'], //可以指定是原图还是压缩图，默认二者都有
				//     // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
				//     sourceType: ['album'], //从相册选择
				//     success: function (res) {
				//         console.log(JSON.stringify(res.tempFilePaths));
				// 		console.log('tempFiles', JSON.stringify(res.tempFiles));
						
				// 		that.user_info[name_ls[index]] = res.tempFilePaths[0];
				// 		console.log('that.user_info', that.user_info);
				//     }
				// });
				return 1
			},
			getImageTextList(index){
				return ["电子签名照片", "身份证正面照\n(国徽面)", "身份证反面照\n(人像面)"][index]
			},
			test22:function(vvv) {  
			                    if (vvv > 0) {  
			                        return true;  
			                    } else {  
			                        return false;  
			                    }  
			                } ,
			//删除 test_image
			selec(index) {
				var dc = {
					0: 'picture_sign',
					1: 'picture_id_card_positive',
					2: 'picture_id_card_negative'
				};
				this.user_info[dc[index]] = undefined;
				// this.img_list.splice(index, 1)
				// this.$emit('obtain_img', this.img_list)
			},
			async clickedverifyCodeButton(user_info) {
				console.log('~~~~~~~ id, user_info: ', this.user_info.id, ' - ', user_info);
				
				if ( user_info ){
					console.log('~~~ 验证成功, 加载用户信息中...');
					this.verified = true;
					
					uni.showToast({
					    title: '加载用户信息中...',
						icon: 'loading',
					    duration: 5000
					});
					var is_submitted = await this.getUserSubmitedInfo();
					console.log('------ is_submitted: ', is_submitted)
					uni.hideToast()
					
					return uni.showToast({
						title: '验证成功!',
						icon: 'success',
						position: 'center',
						duration: 1000,
					});
				}
			},
			preview(urls) {
				this.api.previewImages(urls);
			},
			getImgLs(){
				this.img_ls = [this.user_info.picture_sign];
				console.log('~~ img_ls: ', this.img_ls);
			},
			
			async getUserSubmitedInfo(){
				console.log('--- 尝试获取用户已经提交的信息 ---');
				var myData =  {
						'phone_number': this.user_info.phone_number,
						'order_type_ls': ['-id', ],
				};
				if(! myData['phone_number']){
					// console.log('myData的phone_number为空, 不能查询用户信息!');
					uni.showToast({
						title: 'myData的phone_number为空, 不能查询用户信息!',
						icon: 'none'
					})
					return 0;
				}
				
				// console.log('userinfophonenumber', user_info.phone_number);
				// 设置缓存
				uni.setStorageSync('phone_number', this.user_info.phone_number);
				
				// 加载缓存
				// var value = uni.getStorageSync('phone_number');
				// console.log('====== getStorageSync_value', value, user_info);
				
				
				const res = await this.$myGetFunction({
					url: '/api/index/ForecastRegistration/',
					data: myData,
				})
				console.log('*** myData', myData)
				console.log('***** res: ', res);
				
				var result = res.data.result;
				if (result.data.length == 0){
					console.log('--- 未找到用户信息! 应该是第一次报名.')
					return 0
				}
				
				var resp_user_info = result.data[0];
				
				function test(resolve, reject) {
					// return new Promise(function (resolve, reject) {
						console.log('打开框框~~~~~~~')
						
						var that = this;
						uni.hideToast();
						uni.showModal({
							title: '服务器同步',
							content: '检测到您已有提交记录,\r\n 是否在此基础上进行修改?',
							confirmText: "否",
							// confirmColor: "#000",
							
							cancelText: "是",
							// cancelColor: "#eee",
							success: function(res) {
								console.log('~~~~~~~~~~~ success ', res);
								resolve(res)
								return
							},
							fail: function(res) {
								resolve(res)
								console.log('!!!!!!!!!!!!! fail', res);
							}
						});
					// }
				}
				var p1 = new Promise(test);
				let that = this;
				p1.then(function (result) {
					// var result = JSON.parse(resolve);
				    console.log('成功：' + result.confirm);
					if (result.confirm){
						console.log('~~~~~~~~~~~ 拒绝拉取数据! 仅同步id. end program. ');
						// console.log(resp_user_info);
						that.user_info.id = resp_user_info.id;
						return 0
					}
					// 开始赋值
					let data_dc = that._data
					for(var k in resp_user_info){
						var v = resp_user_info[k];
						
						if (data_dc[k]){
							data_dc[k].value = resp_user_info[k];
						}
						data_dc.user_info[k] = resp_user_info[k];
					}
					that.address = resp_user_info['address_selected'];
					
					console.log(resp_user_info)
					console.log(data_dc)
					return 1
				})
				
				
			},
			getMajors() {
				uni.request({
					method: 'GET',
				    url: this.$baseUrl + '/api/myconf/Major/',
					success: (res) => {
						var data = res.data.result.data;
						
						this.selected_major.names = []
						this.major_list = []
						for(var i = 0; i < data.length; i++){
							var d = data[i]['name'];
							this.selected_major.names.push(d);
						}
						
						// --- (已通过v-model解决)重新加载子组件的两种方案, hackReset: 强制重载, $refs: 直接修改子组件的数据
						// this.hackReset = false;
						// this.$nextTick(() => {
						//    this.hackReset = true;
						// })
						// this.$refs.child.names = this.selected_major.names;    // 这句很重要
					}
				});
				
			},
			picture_sign(e){
				var filePath0 = e.tempFilePaths[0];
				this.user_info.picture_sign = filePath0;
				console.log('选择文件picture_sign：', filePath0);
			},
			picture_id_card_positive(e){
				var filePath0 = e.tempFilePaths[0];
				this.user_info.picture_id_card_positive = filePath0;
				console.log('选择文件picture_id_card_positive：', filePath0);
			},
			picture_id_card_negative(e){
				var filePath0 = e.tempFilePaths[0];
				this.user_info.picture_id_card_negative = filePath0;
				console.log('选择文件picture_id_card_negative：', filePath0);
			},
			addresspick(obj) {
				let arr = [ 'province', 'city', 'area'];
				let place = '';

				arr.map(key => {
					this.form[key] = obj[key].AreaId
					place += obj[key].AreaName + "/"
				})
				place = place.substring(0, place.length - 1);
				this.address = place;
				
				this.user_info.address_selected = place;
				this.user_info.province = obj['province'].AreaName
				this.user_info.city = obj['city'].AreaName
				this.user_info.area = obj['area'].AreaName
			},
			getPickerMsg(res){
				// 仅适用于bdpicker, 将value赋值到对应的组件dc中.
				let data_dc = this._data
				for(var k in data_dc){
					var v = data_dc[k];
					if (v['text'] == res.dc['text'] && v['placeholder'] == res.dc['placeholder']){
						v.value = res.value;
						// 赋予user_info
						data_dc.user_info[k] = v.value;
					}
				}
			},
			getMsg(res){
				// 仅适用于bdinput, 将value赋值到对应的组件dc中.
				let data_dc = this._data
				for(var k in data_dc){
					var v = data_dc[k];
					
					if (v['text'] == res.dc['text'] && v['placeholder'] == res.dc['placeholder']){
						v.value = res.value;
						// 赋予user_info
						data_dc.user_info[k] = v.value;
					}
				}
			},
			
			//*上传图片*//
			async uploadimage1() {
				console.log('---------- 开始上传图片 ------')
				uni.showToast({
				    title: '数据上传中...',
					icon: 'loading',
				    duration: 8000
				});
				var myUrl = this.newUrl;
				// var myUrl = this.$baseUrl + '/api/index/ForecastRegistration/99/';
				const name_ls = ['picture_sign', 'picture_id_card_positive', 'picture_id_card_negative'];
				
				var i = -1;
				var field_name = "";
				var img_path = "";
				// 上传已保存的照片
				// const tempFilePaths = this.imglist;
				console.log('~~~ myUrl:', myUrl);
				
				i += 1;
				field_name = name_ls[i];
				img_path = this.user_info[field_name]
				console.log('~~~~~~~~~~~~~~ i field_name:', i, field_name);
				console.log('---1111111111 img_path ', img_path)
				if (!img_path){
					uni.hideToast()
					
					var msg = '第 ' + (i + 1) + ' 张图片的格式不对!';
					uni.showToast({
						title: msg,
						icon: 'none',
						position: 'center'
					});
					return 0
				}
				
				console.log('~~~~~~~~~~ 开始上传第1张图片! ~~~~~~~~~~~~~')
				// 第一张图片 picture_sign
				await uni.uploadFile({
				    url: myUrl,
				    filePath: img_path,
				    name: field_name,
				    formData: {
						'post_type': 'update',
						'img_path': img_path,
						'from': 'uniapp' ,
				    },
				    success: (uploadFileRes) => {
						console.log('*** uploadFileRes.data', uploadFileRes.data);
						var data = JSON.parse(uploadFileRes.data);
						if(200 <= data.status < 300){
							console.log(i, '*** Update Successfully!', field_name);
						}
						console.log(i, '--- data: ', data);
						
						i += 1;
						field_name = name_ls[i];
						img_path = this.user_info[field_name]
						console.log('~~~~~~~~~~~~~~ i field_name:', i, field_name);
						console.log('--- img_path ', img_path)
						if (!img_path){
							uni.hideToast()
							
							var msg = '第 ' + (i + 1) + ' 张图片的格式不对!';
							uni.showToast({
								title: msg,
								icon: 'none',
								position: 'center'
							});
							return 0
						}
						
						// 第二张图片 picture_id_card_positive'
						uni.uploadFile({
						    url: myUrl,
						    filePath: img_path,
						    name: field_name,
						    formData: {
								'post_type': 'update',
								'img_path': img_path,
								'from': 'uniapp' ,
						    },
							success: (uploadFileRes) => {
								var data = JSON.parse(uploadFileRes.data);
								if(200 <= data.status < 300){
									console.log(i, '*** Update Successfully!', field_name);
								}
								console.log(i, '--- data: ', data);
								
								i += 1;
								field_name = name_ls[i];
								img_path = this.user_info[field_name]
								console.log('~~~~~~~~~~~~~~ i field_name:', i, field_name);
								console.log('--- img_path ', img_path)
								if (!img_path){
									uni.hideToast()
									
									var msg = '第 ' + (i + 1) + ' 张图片的格式不对!';
									uni.showToast({
										title: msg,
										icon: 'none',
										position: 'center'
									});
									return 0
								}
								
								// 第三张图片 picture_id_card_negative
								uni.uploadFile({
								    url: myUrl,
								    filePath: img_path,
								    name: field_name,
								    formData: {
										'post_type': 'update',
										'img_path': img_path,
										'from': 'uniapp' ,
								    },
									success: (uploadFileRes) => {
										var data = JSON.parse(uploadFileRes.data);
										if(200 <= data.status < 300){
											console.log(i, '*** Update Successfully!', field_name);
										}
										console.log(i, '--- data: ', data);
										
										uni.hideToast()
										return uni.showToast({
											title: '数据上传成功!',
											icon: 'success',
											position: 'center'
										});
									},
								})
							},
						})
				    }
				});
				
			},
			
			async uploadimage() {
				console.log('---------- 开始上传图片 ------')
				uni.showToast({
				    title: '数据上传中...',
					icon: 'loading',
				    duration: 8000
				});
				// this.newUrl = '/api/index/ForecastRegistration/848/';
				var myUrl = this.newUrl;
				const name_ls = ['picture_sign', 'picture_id_card_positive', 'picture_id_card_negative'];
				
				var i = 0;
				var field_name = "";
				var img_path = "";
				var tag = ''
				console.log('~~~~~~~~~~ 开始上传图片! ~~~~~~~~~~~~~')
				
				var option_ls = [];
				for (var i = 0; i < 3; i++) {
					field_name = name_ls[i];
					img_path = this.user_info[field_name];
					tag = '第' +　(i+1).toString() + '张图片';
					var option_i = {
						not_add_base_url: true,
						tag: tag,
						url: myUrl,
						filePath: img_path,
						name: field_name,
						formData: {
							'post_type': 'update',
							'img_path': img_path,
							'from': 'uniapp' ,
						},
					};
					
					if (!img_path){
						var msg = option_i.tag + "的地址为空!!!"
						uni.showToast({
							title: msg,
							icon: 'none',
							duration: 1000
						});
						return 0
					}
					
					// option_ls.concat([option_i])
					option_ls[i] = option_i;
				}
				console.log(option_ls);
				var p0 = this.api.uploadFileFunction(option_ls[0]);
				let log = console.log;
				
				let that = this;
				p0.then(function (result) {
					if (that.api.is_contains(result.toString(), '地址为空')){
						return
					}
					
					var p1 = that.api.uploadFileFunction(option_ls[1]);
					p1.then(function (result) {
						if (that.api.is_contains(result.toString(), '地址为空')){
							return
						}
						that.api.uploadFileFunction(option_ls[2]).then(function (result) {
							uni.showToast({
								title: '图片上传成功!',
								icon: 'success',
								duration: 3000
							})
						})
					})
				})
				
				
			},
			
			// 提交基本信息
			async submitBaseInfo() {
				console.log('--- 上传基本信息 ---', this.verified);
				if (!this.verified){
					uni.showToast({
						title: '请先进行手机号验证!',
						icon: 'none',
						position: 'center'
					});
					return
				}
				
				var myUrl = this.$baseUrl + '/api/index/ForecastRegistration/';
				var method = 'POST'
				
				var url_1 = myUrl;		// 根据不同用户, 可能会由post变成put
				console.log('~~~ method, myurl:', method, '-', myUrl);
				
				// 判断是否有为空的数据, 有的话, 就不予提交
				var CHECK_EXIST_EMPTY_FIELD = 1;
				if (CHECK_EXIST_EMPTY_FIELD){
					var data = this.user_info;
					for(var k in data){
						var v = data[k];
						
						// 检查是否user_info中有未填写的字段, 有的话, 就告诉用户
						var warnning_text = '';
						if (!v || (v == undefined)) {
							if (k == 'address_selected'){
								warnning_text = '[地址选择]字段不能为空!'
							}
							else if (k == 'picture_id_card_negative'){
								warnning_text = '[身份证反面_人像面]字段不能为空!'
							}
							else if (k == 'picture_id_card_positive'){
								warnning_text = '[身份证正面_国徽面]字段不能为空!'
							}
							else if (k == 'picture_sign'){
								warnning_text = '[电子签名]字段不能为空!'
							}
							else{
								var base_data_class = this._data[k];
								if (base_data_class){
									warnning_text = '[' + base_data_class.text + ']字段不能为空!';
								}
							}
						}
						console.log('---', k, v, '---', warnning_text);
						if (warnning_text){
							uni.showToast({
								title: warnning_text,
								icon: 'none',
							})
							// console.log(warnning_text);
							return;
						}
						
					}
					// console.log('强制暂停...')
					// return 1;
				}
				
				// 先删除3个图片字段
				var data = JSON.parse(JSON.stringify(this.user_info));
				delete data['picture_id_card_negative']
				delete data['picture_id_card_positive']
				delete data['picture_sign']
				
				if (this.user_info.id != undefined){
					url_1 += this.user_info.id.toString() + '/';
					data.post_type = 'update'
				}
				
				await uni.request({
					method: method,
					url: url_1,
					data: data,
					success: (res) => {
						console.log('--- res.data: ', res.data);
						var result = res.data.result;
						var newUrl = myUrl + result.id.toString() + '/';
						
						console.log('--- newUrl: ', newUrl);
						this.newUrl = newUrl;
						
						// 这里出bug了, xxx is not a function. 这是因为res要用指针=>, 不能直接=等于.
						// this.picture_sign("a");
						this.uploadimage();
					},
					fail(err) {
						uni.showToast({
							title: '获取数据失败',
							icon: 'none',
						})
					}
				})
				
			},
			
			// testing...
			async showName(){
				console.log(this.user_info);
				console.log(this._data);
			},
			
			// 提交数据
			showData() {
				// let data_dc = this._data
				// for(var k in data_dc){
				// 	var v = data_dc[k];
				// 	console.log('~~~ ', k, ' - ',  v);
				// }
				this.submitBaseInfo();
				// this.uploadimage();
			},
			
		}
	}
</script>


<style lang="scss" scoped>
	uni-modal .uni-modal__bd{      
	    white-space: pre-wrap;      
	}
	
	// 标题
	.page-title{
		font-weight:bold;
		font-size: 48upx;
		text-align:center;
		// margin-bottom: 40upx;
	}
	
	// 间隔栏
	.interval_bar{
		height: 20rpx;
		background-color: #F4F5F6;
	}
	
	// 地址选择框视图
	.picker_view {
		width: 100%;
		display: flex;
		border-top: 3upx solid #ccc;
		border-bottom: 3upx solid #ccc;
		padding: 20upx;
	}
	.picker_text {
		width: 25%;
	}
	
	// 地址选择框
	.picker {
		width: 65%;
		float: right;
		display: block;
	}
	.picker_input {
		width: 80%;
		float: left;
		text-align: right;
		margin-right: 10upx;
		// margin-left: 40upx;
	}
	.picker_icons {
		float: right;
		width: 20%;
	}
	
	// 图片容器
	.images_container {
		display: flex;
		justify-content: space-around;
		align-items: center;
		padding-top: 10upx;
		padding-bottom: 10upx;
	}
	.dont_have_img_container {
		height: 175upx;
		
		border-radius: 8rpx;
		position: relative;
		box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, .3);
		display: table; /*重点*/
		
		padding-left: 15upx;
		padding-right: 15upx;
		padding-top: 10upx;
		padding-bottom: 10upx;
	}
	.img_text {
		display: table-cell;
		vertical-align:middle;
		text-align:center;
		font-size: 30upx;
		// border: #000000;
		// margin-top: 50upx;
		// margin-bottom: 10upx;
		// padding-left: 10upx;
		// padding-bottom: 10upx;
	}
	
	.img {
		// margin-left: 5upx;
		// margin-right: 10upx;
		color: #303133;
	}
	
	// 展示图片的容器
	.show_img_container {
		position: relative;
	}
	.show_img {
		width: 135upx;
		height: 135upx;
		margin-left: 5upx;
		margin-right: 10upx;
		color: #303133;
		position: relative;
		
		border-color: #aeafb3;
		border-width: 2;
		border-radius: 2px;
		border-style: dashed;
		padding: 20upx,
	}
	
	// 删除图标 test_image
	.shancs {
		width: 8vw;
		height: 8vw;
		color: #eee;
		position: absolute;
		top: -5upx;
		right: -3upx;
		z-index: 1;
	}
	
	.buttons {
		display: flex;
		padding: 10upx;
		.check_button {
			float: left;
			background-color: $background-color;
			color: #fff;
		}
		.submit_button {
			width: 400upx;
			float: right;
			background-color: $background-color;
			color: #fff;
		}
	}
	
</style>
